﻿package Component {
	
	import flash.display.MovieClip;
	import flash.utils.Timer;
	import flash.events.Event;
	
	public class Clock extends MovieClip {
		
		private var count:uint;
        private var ticker:Timer;
		
		public function Clock() {
			ticker = new Timer(1000, 0);
			ticker.stop();
            ticker.addEventListener("timer", update);
		}
		
		public function reset(seconds:uint) {
			count = seconds;
			update();
			ticker.start();
		}
		
		public function update(e:Event = null) {
			
			secondes.text = (count%60).toString();
			minutes.text = ((uint)(count/60)).toString();
			
			if(count == 0) {
				ticker.stop;
				return;
			}
			count--;
		}
		
		
	}
	
}
